﻿using Microsoft.Extensions.Configuration;

namespace cap01.Common;

/// <summary>
/// 应用配置（使用前请先初始化）
/// </summary>
public class AppConfig
{
    private static readonly AppConfig _settings = new();
    public static AppConfig Settings => _settings;
    public static void Init()
    {
        var config = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory())
            .AddJsonFile("./appsettings.json");
        if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development")
        {
            config.AddJsonFile("./appsettings.Development.json");
        }
        var manager = config.Build();
        manager.Bind(_settings);
    }

    /// <summary>
    /// 是否重新创建数据库
    /// </summary>
    public bool IsBuild { get; set; }

    /// <summary>
    /// 过期时间（秒）
    /// </summary>
    public int ExpireSecond { get; set; }

    /// <summary>
    /// Redis连接
    /// </summary>
    public string RedisConnection { get; set; }

    /// <summary>
    /// 实例名
    /// </summary>
    public string InstanceName { get; set; }

    /// <summary>
    /// Rabbitmq连接
    /// </summary>
    public string RabbitmqConnection { get; set; }

    /// <summary>
    /// 
    /// </summary>
    public string SqlserverConnection { get; set; }

    /// <summary>
    /// 
    /// </summary>
    public string MySqlConnection { get; set; }

    /// <summary>
    /// 数据库类型
    /// </summary>
    public string DbType { get; set; }

}
